<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/2/20
 * Time: 8:36
 */
namespace app\admin\controller;


use think\Db;
use think\Request;
class About extends Base {
    /**
     * 注册协议
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 1)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 1)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/zhuce');
    }

    /**
     * 隐私协议
     * @return mixed|\think\response\Json
     */

    public function yinsi(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 2)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 2)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/yinsi');
    }
    /**
     * 关于我们
     * @return mixed|\think\response\Json
     */
    public function about(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 3)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 3)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/about');
    }
    /**
     * 尺寸图
     * @return mixed|\think\response\Json
     */
    public function mypage(){
        if(Request::instance()->isPost()){
            $about_content = input('content');
            $res = Db::table('up_about')->where('id', 4)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id',4)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/sizepic');
    }
}